﻿@model POCOS.Auteur
@{
    ViewBag.Title = "Index";
}





<script type="text/javascript">
    function AddUser() {
       
    var auteur =
    {
        "Name": $(Name).val(),
        "Lastname": $(Lastname).val(),
        "Profil": $(Profil).val(),
        "Adressmail": $(Adressmail).val()
    };
   

        $.ajax({
            url: '/Auteur/AddUser/',
            data: JSON.stringify(auteur),
            type: 'POST',
            contentType: 'application/json; charset=utf-8',
            success: function (data) {
                var output ;
                output += '<ul>' + '<li>' + data.Status + '</li>' + '</ul>';
                $("#msg").html(output);
               
               
            }
        });

}
    </script>
<script type="text/javascript">
   
    $(document).ready(function () {
        $('#adduser').click(function (e) {
            e.preventDefault();
           
                $.ajax({
                    url: $("#addNewUserForm").attr('action'),
                    type: $("#addNewUserForm").attr('method'),
                    data: $("#addNewUserForm").serialize(),
                    success: function (data) {
                        alert(data.Status);
                    }
                });
           
        });
    });
</script>

@using (Html.BeginForm("AddUser", "Auteur", FormMethod.Post, new { id = "addNewUserForm" }))
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

<table>
    <caption> أكمل تعمير المعلومات حول نفسك </caption>


       
              
       

       <tr>
            <td>
                  @Html.EditorFor(model => model.Name)
                @Html.ValidationMessageFor(model => model.Name)
            </td>
       </tr>
       <tr>
            <td>
                  @Html.EditorFor(model => model.Lastname)
            @Html.ValidationMessageFor(model => model.Lastname)
            </td>
        </tr>
       <tr>
           <td>
                 @Html.EditorFor(model => model.Profil)
            @Html.ValidationMessageFor(model => model.Profil)
           </td>
        </tr>
       <tr>
            <td>
                  @Html.EditorFor(model => model.Adressmail)
            @Html.ValidationMessageFor(model => model.Adressmail)
            </td>
        </tr>
        
        
      <tr>
            <td>   <input id="adduser-changed" type="button" value="Add User" onclick="AddUser()"/> </td>
          <td><div id="msg"></div></td>
           
        </tr>
        
      
 

</table>

}

<link href="~/Content/GridStyle.css" rel="stylesheet" />
@*@{
    var grid = new WebGrid(
        Model, rowsPerPage: 5,
        defaultSort: "Name",
        columnNames: new[] { "Id", "Name", "Lastname", "Profil", "Adress Mail" }
        );
}

@grid.GetHtml(

tableStyle:"webgrid-table",
headerStyle:"webgrid-header",
footerStyle:"webgrid-footer",
alternatingRowStyle:"webgrid-alternating-row",
rowStyle:"webgrid-row-style",
fillEmptyRows:false,
mode:WebGridPagerModes.All,
columns:grid.Columns
(

grid.Column("Name",header:"الإسم" + GUI.Helpers.HelpersGrid.SortDirection(null,ref grid,"Name"),style:"name"),
grid.Column("Lastname",header:"اللقب" + GUI.Helpers.HelpersGrid.SortDirection(null,ref grid,"Lastname"),style:"Lastname"),
grid.Column("Profil",header:"لمحة", canSort:false,style:"Profil"),
grid.Column("Adressmail",header:"العنوان إلكتروني" + GUI.Helpers.HelpersGrid.SortDirection(null,ref grid,"Adressmail "),style:"Adressmail"),
grid.Column("Id",header:"المقالات",format:item => Html.ActionLink("Articles","Index","Articles",new { id=item.Id },null)),
grid.Column("",
                header: "Actions",
                format: @<text>
                    <img src="~/Images/edit.png" alt="Modifier" onclick="EditTest('@item.Id')"/>|
                   <img src="~/Images/delete.png" alt="Delete"  onclick="DeleteTest('@item.Id')" />                  
                       
                        </text>
                )
                

)
)*@






           @* @Html.ActionLink("Edit", "Edit", new { id=item.Id }) |
            @Html.ActionLink("Details", "Details", new { id=item.Id }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.Id })*@
